import request from '../utils/request.js'

/**
 * 获取资讯列表
 * @param {string} category - 分类
 * @param {string} keyword - 关键词
 */
export function getNewsList(category = 'all', keyword = '') {
  return request({
    url: '/api/news/list',
    method: 'GET',
    data: { category, keyword }
  })
}

/**
 * 获取资讯详情
 * @param {number} id - 资讯ID
 */
export function getNewsDetail(id) {
  return request({
    url: `/api/news/${id}`,
    method: 'GET'
  })
}

/**
 * 点赞资讯
 * @param {number} id - 资讯ID
 */
export function likeNews(id) {
  return request({
    url: `/api/news/like/${id}`,
    method: 'POST'
  })
}

/**
 * 获取热门资讯
 */
export function getHotNews() {
  return request({
    url: '/api/news/hot',
    method: 'GET'
  })
}
